<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/flow/include/common-base.jsp"%>
  <title>任务审核</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/flow/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/flow/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-edit"></i> 任务审核</h3>
				<div class="form-group">
					<div class="form-group col-sm-2 text-right"><label class="control-label" >任务名称：</label></div>
					<div class="col-sm-4">
						<span class="control-label">${param.taskName}</span>
					</div>
					<div class="form-group col-sm-2 text-right"><label class="control-label" >发生时间：</label></div>
					<div class="col-sm-4">
						<span class="control-label" id="createTimeLabel">${param.createTime}</span>
						<script type="text/javascript">
							$("#createTimeLabel").html(formatDate(parseInt('${param.createTime}'),'yyyy-MM-dd'));
						</script>
						
					</div>
				</div>
            </div>
            
            <div class="box-body" id="bodyProView">
            
            
            </div>
            
            <div class="box-body">
            
			  <form id="auditForm" class="form-horizontal" action="javascript:;">
				<input type="hidden" name="formToken" class="formToken"/>
				<input type="hidden" name="auditFlag" id="auditFlag" value="T"/>
				<input type="hidden" name="pageName" value="${param.pageName}"/>
				<input type="hidden" name="formName" value="${param.formName}"/>
				<input type="hidden" name="taskName" value="${param.taskName}"/>
				<input type="hidden" name="auditsId" value="${param.auditsId}"/>


				<!-- 插件中用的个性化参数  -->
				  <input type="hidden" name="result" value="1"/>
				  <!-- 插件中用的个性化参数  -->
				
				
				
				<div class="form-group">
					<div class="form-group col-sm-2 text-right"><label class="control-label" >审核意见：</label></div>
					<div class="col-sm-8">
						<textarea class="form-control" rows="3" id="auditOpinion" name="auditOpinion"  maxLength="200" placeholder="最多输入2000字" ></textarea>
					</div>
				</div>
				
				<div class="form-group">
					<div class="col-sm-12 text-center">
						<button class="btn  btn-lg" type="button" onclick="history.go(-1)"> 返 回 </button>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<button class="btn btn-success btn-lg" type="button" onclick="submitAudit('T');"><i class="fa fa-check"></i> 审核通过 </button>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				        <button class="btn btn-danger btn-lg" type="button" onclick="submitAudit('F');"><i class="fa fa-close"></i> 审核不通过 </button>
					</div>
				</div>
				
			  </form>
			  
            </div>
            
	     </div>
           
       
        </div>
      </div>
    </section>
    <!-- Main end -->

    <!-- Part 三、 以下是js模块区域 -->
<script>
var clickMenu = "audit-list";

$(function () {
	var linkUrl = "${param.linkUrl}";
	if(strUtil.isNull(linkUrl)){
		layer.alert("审核规则中没有设置引用地址！");
		mytools.load("${ctx}/sendPage/task/task-list");
	}
	//1、加载数据
	$("#bodyProView").load("${ctx}/sendPage/"+"${param.sysName}"+"/admin"+linkUrl+" .viewForm",function(resultData){
		 $result = $(resultData);
         $result.find("#viewForm_hidden").appendTo("#bodyProView");
         var searchPageName=$("#viewForm_hidden").find("input[name='pageName']").val();
         var searchFormName=$("#viewForm_hidden").find("input[name='formName']").val();
         
         $result.find("#hidden_common_final").appendTo("#bodyProView");
         var objName=$("#hidden_common_final").find("input[name='mainObjName']").val();
         var primarkey=$("#hidden_common_final").find("input[name='mainObjPrimaryKey']").val();
         var proId = "${param.proId}";
         // alert(searchPageName+"|"+searchFormName+"|"+proId+"|"+objName);
         var paramData={};
         paramData["pageName"]=searchPageName;
         paramData["formName"]=searchFormName;
         paramData["objName"]=objName;
         paramData[objName+".w_"+primarkey]=proId;
      	 loadProView(paramData);
      	 
         var dymicHtml = "<input type=\"hidden\" name=\""+objName+".w_"+primarkey+"\" value=\""+proId+"\"/>"
         $("#auditForm").prepend(dymicHtml);
       	//  $("#auditForm").prepend($result.find("#auditForm_hidden"));
       	
	});
	//2、控制是否启用token
	
	setToken();
 });


function loadProView(paramData){
	console.log(paramData);
	$.ajax({
	    type:'get',
	   	url:common_info_url,
	    data: paramData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	console.log("loadProView---------->",myData);
	    	//var objName=paramData.objName;
			//FormUtil.loadView(objName, myData[objName]);
			//反显加载数据
	    	if(myData){
				for(var objNameKey in myData){
					var ownerType = myData[objNameKey].ownerType;
					FormUtil.loadView(objNameKey, myData[objNameKey]);
				}
			}
	  	}
	});
}

//设置token
function setToken(){
	$.ajax({
	    type:'get',
	    url:ctx+'/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			$('.formToken').val(myData);
	  	}
	});	
}

//审核提交
function submitAudit(auditFlag){
	var auditOpinion = $('#auditOpinion').val();
	if("F"==auditFlag && strUtil.isNull(auditOpinion)){
		layer.tips('请输入审核意见', '#auditOpinion', {tips: 2});
		$('#auditOpinion').focus();
		return;
	}
	
	var auditStatus = "${param.taskNum}0";
	if(auditFlag=="T"){
		auditStatus = "${param.taskNum}1";
	}
	
	$("#auditFlag").val(auditFlag);
		
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var index_load = layer.load(1, {shade: false});
		setToken();
		$.ajax({
		    type:'post',
		    url:common_submit_url,
		    data:$("#auditForm").serialize(),
		    dataType:'json',
		    success: function(myData){
		     //console.log(myData);
		     	layer.close(index_load);
		    	if(myData.flag=='T'){
		    		layer.alert("操作成功！");
		    		var url = "${page_admin}/task/task-list";
	    			mytools.load(url);
		    	}else{
		     		layer.alert(myData.msg);
		    	}
		  	}
		});	
	}, function(){});
}

</script>
    
    
    
    
    
    
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/flow/foot.jsp" %>
  <!-- foot start -->
  


</body>




</html>





